{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ecf1530a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.1使用数组下标访问，像素坐标（100，100）3个通道（B,G,R）的值:  [78 21  0]\n",
      "1.2使用数组下标访问，像素坐标（100，100）第1个通道(B)的值:  78\n",
      "2.1使用numpy 性能优化的函数访问，像素坐标(100,100) 3 个通道(B,G,R)的值： 78 21 0\n",
      "2.2使用numpy 性能优化的函数设置，像素坐标(100,100) 第3 个通道(R)的值\n",
      "2.3使用numpy 性能优化的函数访问，像素坐标(100,100) 第3 个通道(R)的值： 100\n"
     ]
    }
   ],
   "source": [
    "import cv2 as cv\n",
    "\n",
    "img =cv.imread('../data/GiteeOrGithub.jpeg')\n",
    "if  img is None:\n",
    "    print(\"[ERROR] fail to reada Image!!!\")\n",
    "    exit(0)\n",
    "    \n",
    "px =img[100,100]\n",
    "print('1.1使用数组下标访问，像素坐标（100，100）3个通道（B,G,R）的值: ',\n",
    "     px )\n",
    "blue = img[100,100,0]\n",
    "print('1.2使用数组下标访问，像素坐标（100，100）第1个通道(B)的值: ',\n",
    "     blue )\n",
    "print( '2.1使用numpy 性能优化的函数访问，像素坐标(100,100) 3 个通道(B,G,R)的值：', \n",
    "      img.item(100,100,0), img.item(100,100,1), img.item(100,100,2) )\n",
    "\n",
    "print( '2.2使用numpy 性能优化的函数设置，像素坐标(100,100) 第3 个通道(R)的值' )\n",
    "img.itemset((100,100,2),100)\n",
    "\n",
    "print( '2.3使用numpy 性能优化的函数访问，像素坐标(100,100) 第3 个通道(R)的值：', \n",
    "      img.item(100,100,2) )\n",
    "\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc586b04",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
